{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true
   },
   "source": [
    "# 梯度下降法模拟"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import matplotlib.pyplot as plt"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "plot_x = np.linspace(-1,6,141)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([-1.  , -0.95, -0.9 , -0.85, -0.8 , -0.75, -0.7 , -0.65, -0.6 ,\n       -0.55, -0.5 , -0.45, -0.4 , -0.35, -0.3 , -0.25, -0.2 , -0.15,\n       -0.1 , -0.05,  0.  ,  0.05,  0.1 ,  0.15,  0.2 ,  0.25,  0.3 ,\n        0.35,  0.4 ,  0.45,  0.5 ,  0.55,  0.6 ,  0.65,  0.7 ,  0.75,\n        0.8 ,  0.85,  0.9 ,  0.95,  1.  ,  1.05,  1.1 ,  1.15,  1.2 ,\n        1.25,  1.3 ,  1.35,  1.4 ,  1.45,  1.5 ,  1.55,  1.6 ,  1.65,\n        1.7 ,  1.75,  1.8 ,  1.85,  1.9 ,  1.95,  2.  ,  2.05,  2.1 ,\n        2.15,  2.2 ,  2.25,  2.3 ,  2.35,  2.4 ,  2.45,  2.5 ,  2.55,\n        2.6 ,  2.65,  2.7 ,  2.75,  2.8 ,  2.85,  2.9 ,  2.95,  3.  ,\n        3.05,  3.1 ,  3.15,  3.2 ,  3.25,  3.3 ,  3.35,  3.4 ,  3.45,\n        3.5 ,  3.55,  3.6 ,  3.65,  3.7 ,  3.75,  3.8 ,  3.85,  3.9 ,\n        3.95,  4.  ,  4.05,  4.1 ,  4.15,  4.2 ,  4.25,  4.3 ,  4.35,\n        4.4 ,  4.45,  4.5 ,  4.55,  4.6 ,  4.65,  4.7 ,  4.75,  4.8 ,\n        4.85,  4.9 ,  4.95,  5.  ,  5.05,  5.1 ,  5.15,  5.2 ,  5.25,\n        5.3 ,  5.35,  5.4 ,  5.45,  5.5 ,  5.55,  5.6 ,  5.65,  5.7 ,\n        5.75,  5.8 ,  5.85,  5.9 ,  5.95,  6.  ])"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "plot_x"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 简单的2次曲线\n",
    "plot_y = (plot_x - 2.5)**2 - 1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYIAAAEMCAYAAADJQLEhAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4xLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvAOZPmwAAIABJREFUeJzt3Xl4VdW5x/HvmzmBJBBIIBAIgTDPGJlVEBQFFLVWcapaq1br0F6vrfV2vq12slWcWmduRVRwVhwRBRGEADKGMSSEMWFMIHPy3j9y6EUvCYck56xzct7P8+wnyTFk/2TIL3uvtdcSVcUYY0zoCnMdwBhjjFtWBMYYE+KsCIwxJsRZERhjTIizIjDGmBBnRWCMMSHOisAYY0KcFYExxoQ4KwJjjAlxEa4DeKN9+/barVs31zGMMSaorFixYr+qJp/q84KiCLp160Z2drbrGMYYE1REJN+bz7NbQ8YYE+KsCIwxJsRZERhjTIizIjDGmBBnRWCMMSHOisAYY0KcFYExxoS4Fl0E763Zw6yvvJpGa4wxAWXX4TL++P5GCkvKfX6uFl0E89bu4a8fbqKiusZ1FGOMOS2vLC/gnwu3UVld6/NztegiuPLMLhwqreLD9ftcRzHGGK/V1Cpzsgs4q2cyaW3jfH6+Fl0EYzPbk9Y2lleW73AdxR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hgGPCkqg4FjgE+GztsMZvXq+pE1xmaYBfQ5YSP0zyvmWYgIpHUlcAsVX3ddR5vqephEVlA3XhMIA7MjwEuFpHJQAyQICIvquq1jnPVS1V3ed4Wisgb1N2WDcSxw53AzhOuBufiwyJoMVcEQW450FNEMkQkCpgOvO04U4sgIkLdfdYcVf2b6zynIiLJItLG834scB6w0W2qk1PVn6tqmqp2o+7v7KeBXAIi0kpE4o+/D5xPYBYsqroXKBCR3p6XJgAbfHW+kCgCEblURHYCo4D3RORD15lOpKrVwB3Ah9QNZr6qquvdpqqfiMwGlgC9RWSniNzkOlMDxgDXAed6pgx+7fkJNlClAgtEZA11PyB8rKoBPy0zSHQAvhCR1cAy4D1V/cBxpobcCczy/F0YAjzgqxPZk8XGGBPiQuKKwBhjTP2sCIwxJsRZERhjTIizIjDGmBBnRWCMMSHOisAYY0KcFYExxoQ4KwJjGsGzMNwjnj0D1opId9eZjGksKwJjGufnQK6q9gdmALc7zmNMo7WYReeM8RfPOjWXquoZnpe2U7cmvzFByYrAmNM3Eeji2TMAIAn4xGEeY5rEbg0Zc/qGAL/ybHc4BPgI+PoUv8aYgGVFYMzpawuUAohIBHXLGb/jNJExTWBFYMzp2wwc31D+J9QtZ7zdYR5jmsSWoTbmNIlIW+B9oD11+zLcoqplblMZ03hWBMYYE+Ls1pAxxoQ4KwJjjAlxVgTGGBPirAiMMSbEWREYY0yIsyIwxpgQZ0VgjDEhzorAGGNC3P8CNxK6aIiZIx0AAAAASUVORK5CYII=\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x10681a5f8>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.plot(plot_x, plot_y)\n",
    "plt.xlabel(r'$\\theta$')\n",
    "plt.ylabel('J (Loss Function)')\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 求损失函数J某一点上的导数\n",
    "def dJ(theta):\n",
    "    return 2*(theta-2.5)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 损失函数J本身\n",
    "def J(theta):\n",
    "    return (theta - 2.5)**2 - 1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2.499891109642585\n-0.99999998814289\n"
     ]
    }
   ],
   "source": [
    "eta = 0.1 # 学习率/步长\n",
    "epsilon = 1e-8\n",
    "\n",
    "theta = 0.0 # 初始值（随机，我们先设为0）\n",
    "\n",
    "while True:\n",
    "    gradient = dJ(theta)\n",
    "    last_theta = theta\n",
    "    theta = theta - eta*gradient\n",
    "    \n",
    "    # 注意这里必须是用绝对值，否则有可能会让损失函数变得更大\n",
    "    if (abs(J(theta) - J(last_theta)) < epsilon):\n",
    "        break\n",
    "\n",
    "print(theta)\n",
    "print(J(theta))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "由上图可知，损失函数最小值为1，对应的θ是2.5，因此我们的手写梯度下降法大致成功了"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "看看θ的轨迹"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXQAAAD8CAYAAABn919SAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4xLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvAOZPmwAAIABJREFUeJzt3Xd41tX9//HnOzuBJIwkkAUJe4MYIQwVEMWBOKugqDhA66i0Vn/YRbSt9mu1dU9EqaAgiIqKiiLIEISwZK9ANiEEyCBkn98fCRYpI3DfybnH+3FduUju3PB5ifjieM75nI8YY1BKKeX+fGwHUEop5Rxa6Eop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3RTGemA/8I0xxpXzPg88BtTYDlJPBlggImtEZILtMKeRCOQD79RNZ00RkSYNdTGXK3QR+VZENp3kw2VHuqrxiEhT4CNgojGmyHae0zHGVBtj+gBxQD8R6WE708mIyEhgvzFmje0sZ2GwMaYvtdObD4jIRbYDnYIf0Bd4zRhzHnAEaLC1NZd7YpExZrjtDA7IBuKP+zqu7jXlBCLiT22ZzzDGzLWdp76MMYdFZBG16xWuuAA9CBglIlcCQUCYiEw3xoy1nOuUjDHZdT/uF5GPqZ3udMW1tSwg67j/O5tDAxa6y43Q3dxqoKOIJIpIADAamGc5k0cQEaF2HnKrMeZftvOciYhEikizus+DgUuBbXZTnZwx5nFjTJwxJoHaP7PfuXKZi0gTEQk99jlwGa75FyXGmH1Apoh0rnvpEmBLQ13PrQpdRK4TkSxgAPCFiHxtO9PxjDFVwIPA19Qu2n1ojNlsN9WpicgHwAqgs4hkicjdtjOdxiDgNmBY3Va19XUjSlcVDSwSkZ+o/Yv+G2OMy28HdBOtgGUisgFYBXxhjPnKcqbTeQiYUfdnoQ/wVENdSO8UVUopD+FWI3SllFKnpoWulFIeQgtdKaU8hBa6Ukp5CC10pZTyEFroSinlIbTQlVLKQ2ihK6WUh/j/8bxBg47CQ9sAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x106cd2240>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "eta = 0.1 # 学习率/步长\n",
    "theta = 0.0 # 初始值（随机，我们先设为0）\n",
    "theta_history = [theta]\n",
    "while True:\n",
    "    gradient = dJ(theta)\n",
    "    last_theta = theta\n",
    "    theta = theta - eta*gradient\n",
    "    theta_history.append(theta)\n",
    "    \n",
    "    # 注意这里必须是用绝对值，否则有可能会让损失函数变得更大\n",
    "    if (abs(J(theta) - J(last_theta)) < epsilon):\n",
    "        break\n",
    "        \n",
    "plt.plot(plot_x, plot_y)\n",
    "plt.plot(np.array(theta_history), J(np.array(theta_history)),color='r',marker='+')\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "46"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len(theta_history)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "把上面的梯度下降方法以及看梯度下降轨迹的方法封装一下"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [],
   "source": [
    "def gradient_descent(initial_theta, eta, epsilon=1e-8):\n",
    "    theta = initial_theta\n",
    "    theta_history.append(initial_theta)\n",
    "    \n",
    "    while True:\n",
    "        gradient = dJ(theta)\n",
    "        last_theta = theta\n",
    "        theta = theta - eta*gradient\n",
    "        theta_history.append(theta)\n",
    "        \n",
    "        if (abs(J(theta) - J(last_theta)) < epsilon):\n",
    "            break\n",
    "\n",
    "def plot_theta_history():\n",
    "    plt.plot(plot_x, J(plot_x))\n",
    "    plt.plot(np.array(theta_history), J(np.array(theta_history)), color='r', marker='+')\n",
    "    plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXQAAAD8CAYAAABn919SAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4xLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvAOZPmwAAIABJREFUeJzt3Xl8VdW9NvDnlzmQCchAQhISZsKMkVlAwaKiWIdWnCrWaltrta3V19p7S7jv+1Hba1uttraoKBUUBKnSOqAiEWROmOchZIQMBMg8nXPW+8c5gRAzkTOss/d5vp9PPuTsHNiPER4Wa6+9tiilQERExuenOwAREbkGC52IyCRY6EREJsFCJyIyCRY6EZFJsNCJiEyChU5EZBIsdCIik2ChEx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vhSRA218eO1IlzxHRMIAfADgF0qpSt15OqKUsiqlxgJIBDBBREbqztQWEbkZQKlSKlt3liswTSk1HvbpzZ+JyHTdgdoRAGA8gNeUUuMA1ABw27U1r3tikVJqtu4MTigCkNTidaLjGLmAiATCXubLlVJrdOfpKqXUBRHZAPv1Cm+8AD0VwDwRuQlACIAIEVmmlLpPc652KaWKHD+Wisi/YJ/u9MZra4UAClv862w13FjoXjdCN7idAAaLSKqIBAGYD2Ct5kymICIC+zzkYaXUn3Tn6YyIxIhIlOPzUADXAziiN1XblFK/UUolKqVSYP89+5U3l7mI9BSR8ObPAXwH3vkXJZRSxQAKRGSo49AsAIfcdT5DFbqI3CYihQAmA/hYRNbpztSSUsoC4DEA62C/aPe+Uuqg3lTtE5H3AGwFMFRECkXkId2ZOjAVwP0ArnMsVdvjGFF6q3gAG0RkH+x/0X+hlPL65YAGEQfgGxHZC2AHgI+VUp9pztSRnwNY7vi9MBbAc+46Ee8UJSIyCUON0ImIqH0sdCIik2ChExGZBAudiMgkWOhERCbBQiciMgkWOhGRSbDQiYhM4v8DB3FabCGxl5UAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x106a89a90>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "eta = 0.01\n",
    "theta_history = []\n",
    "gradient_descent(0., eta)\n",
    "plot_theta_history()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "424"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 步长变小\n",
    "len(theta_history)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "步长η取大一些"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXQAAAD8CAYAAABn919SAAAABHNCS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     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "eta = 0.8\n",
    "theta_history = []\n",
    "gradient_descent(0., eta)\n",
    "plot_theta_history()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "把gradient_descent改进一下，增加限制循环次数"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [],
   "source": [
    "def gradient_descent(initial_theta, eta, n_iters=1e4, epsilon=1e-8):\n",
    "    theta = initial_theta\n",
    "    theta_history.append(initial_theta)\n",
    "    iters = 0\n",
    "    while iters < n_iters:\n",
    "        gradient = dJ(theta)\n",
    "        last_theta = theta\n",
    "        theta = theta - eta*gradient\n",
    "        theta_history.append(theta)\n",
    "        \n",
    "        if (abs(J(theta) - J(last_theta)) < epsilon):\n",
    "            break\n",
    "        iters += 1"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "看一下如果步长η取值过大时会发生什么"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXoAAAD8CAYAAAB5Pm/hAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4xLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvAOZPmwAAIABJREFUeJzt3XlwXNWdL/DvT6u1L5Ysy1q8G1vyIi9gCARMQkgCYSAbScjLEEJi/gh5L1WpelnmvbJ5U1OPyUKKPDKpOG+owFTCkgQCA2FLJoQ3EDYbs3iX8SZbliVbsiVL1vp7f/z65t7u22q1Wmr19v1U3erWvbdbpzH6ntvnnHuOqCqIiCh9ZSW6AEREFF8MeiKiNMegJyJKcwx6IqI0x6AnIkpzDHoiojQ3YdCLSIOI/FlEdovILhH5b4H9W0XkuIjsDGzXeV7zXRFpFZF9IvLReH4AI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eBj270RJQlVfAnAmZPeNAB4IPH8AwE0zWqgpGuczJQSDfvrVATjm+bktsC9V3Ski7wS+hqbUV2ePdPs38VIAz4vIdhHZnOjCTLMaVW0PPD8JoCaRhZlGM/43xaCPQET+KCLvhdnS5mpwgs/4MwCLAbQAaAfwo4QWlsK5QlXXwZqlvi4iVya6QPGgNjwwHYYIJuRvKm5LCaYDVb0mhpcdB9Dg+bk+sC8pRfsZReQXAJ6Kc3HiJaX+TSZDVY8HHk+JyOOwZqqXIr8qZXSISK2qtotILYBTiS7QVKlqh/N8Jv+meEU//Z4E8HkRyReRhQCWAng9wWWKSeCPy/FJWAd0KnoDwFIRWSgiebDO8icTXKYpE5EiESlxngO4Fqn7bxTOkwBuDTy/FcATCSzLtEjU3xSv6GMkIp8E8H8AVAN4WkR2qupHVXWXiDwKYDeAEQBfV9XRRJZ1Cr4vIi2wr8yHAdyR2OLERlVHROROAM8ByAZwv6ruSnCxpkMNgMdFBLC/5V+r6rOJLVJsROQhAJsAVIlIG4AtAO4G8KiI3A6b3fbmxJVw8sb5TJsS8TfFO2OJiNIcm26IiNIcg56IKM0x6ImI0hyDnogozTHoiYjSHIOeiCjNMeiJiNIcg56IKM39f8nQP/ovQlLtAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x106898358>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "eta = 1.1\n",
    "theta_history = []\n",
    "gradient_descent(0., eta, n_iters=10)\n",
    "plot_theta_history()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 2",
   "language": "python",
   "name": "python2"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}
